package com.yunji.common.enums.business;

import com.yunji.common.utils.bean.BeanUtils;
import lombok.Getter;

import java.util.Objects;

/**
 * @Project: yunji-coffee
 * @Package: com.yunji.order.emuns
 * @Title: TradeMode
 * <p>
 * History:
 * Date                     Version     Author          Summary
 * ============================================================
 * 2024-10-26 17:50:17      V1.0        HuaAo       新建类
 */

@Getter
public enum TradeMode {
    NOT_EXISTS(-1, "无"),
    ORDER(0, "收益"),
    PAYOUT(1, "提现"),
    REFUND(2, "收益退款");
//    SCALE(3, "分润", 4),
//    SCALE_REFUND(4, "分润退款", -1);

    private final Integer code;
    private final String text;

    TradeMode(Integer code, String text) {
        this.code = code;
        this.text = text;
    }

    public static TradeMode get(Integer code) {
        if (BeanUtils.isNull(code)) {
            return null;
        }
        TradeMode[] enums = TradeMode.values();
        for (TradeMode e : enums) {
            if (Objects.equals(e.code, code)) {
                return e;
            }
        }
        return TradeMode.NOT_EXISTS;
    }
}